package com.main;
import com.xmlreader.*;
import java.util.ArrayList;
import java.util.List;

import com.NewsFeedClasses.NewsFeed;
import com.NewsFeedClasses.NewsFeedPosts;
import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
public class UserInfo {
		
		public static void getUserInfo(String tokenFile){
			ArrayList<String> tokenList = TokenReader.readXML(tokenFile);
			ArrayList<FBUser> fbuser = new ArrayList<FBUser>();
			for(int i=0;i<tokenList.size(); i++){				
				FacebookClient facebookClient = new DefaultFacebookClient(tokenList.get(i));
				fbuser.add(new FBUser(facebookClient));
			}
			XMLGenerator.generateUserXML(fbuser);
		}
		
		public static void getNewsFeedInfo(String tokenFile){
			ArrayList<String> tokenList = TokenReader.readXML(tokenFile);
			//Here I am assuming that tokens.xml has only one token
			FacebookClient facebookClient = new DefaultFacebookClient(tokenList.get(0));
			FBUser user = new FBUser(facebookClient);
			ArrayList<NewsFeed> newsFeedList = (new NewsFeedPosts(facebookClient)).fetchNewsFeedPosts();
			
			XMLGenerator.generateNewsFeedXML(user, newsFeedList);
		}
		
		public static void getEventsInfo(String tokenFile){
			ArrayList<String> tokenList = TokenReader.readXML(tokenFile);
			//Here I am assuming that tokens.xml has only one token
			FacebookClient facebookClient = new DefaultFacebookClient(tokenList.get(0));
			FBUser user = new FBUser(facebookClient);
			List<EventObject> eventsList = (new Events(facebookClient)).getEventList();
			
			XMLGenerator.generateEventsXML(user, eventsList, facebookClient);
		}

}
